@echo off
chcp 65001 >nul

echo 🔧 修复 .env 文件编码问题...

REM 备份原文件
copy .env .env.backup

REM 创建新的 .env 文件
(
echo # 数据库配置
echo DATABASE_URL="mysql://offgrid_db:123456@120.26.141.225:3306/offgrid_db"
echo.
echo # 服务器配置
echo HOST=0.0.0.0
echo PORT=3888
echo NODE_ENV=development
echo.
echo # JWT配置
echo JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
echo JWT_EXPIRES_IN=7d
echo JWT_REFRESH_EXPIRES_IN=30d
echo.
echo # 跨域配置
echo CORS_ORIGIN=http://localhost:5173,http://localhost:3888,http://192.168.0.19:3888,http://192.168.0.19:5173
echo.
echo # 日志配置
echo LOG_LEVEL=info
echo LOG_FILE=logs/app.log
echo LOG_MAX_SIZE=10m
echo LOG_MAX_FILES=5
echo.
echo # 文件上传配置
echo UPLOAD_PATH=uploads
echo MAX_FILE_SIZE=5242880
echo.
echo # 邮件配置（可选）
echo SMTP_HOST=smtp.gmail.com
echo SMTP_PORT=587
echo SMTP_USER=your-email@gmail.com
echo SMTP_PASS=your-app-password
echo.
echo # Redis配置（可选，用于缓存和会话）
echo REDIS_HOST=127.0.0.1
echo REDIS_PORT=6379
echo REDIS_PASSWORD=
echo.
echo # API限流配置
echo RATE_LIMIT_WINDOW_MS=900000
echo RATE_LIMIT_MAX_REQUESTS=100
echo.
echo # 安全配置
echo BCRYPT_ROUNDS=12
echo SESSION_SECRET=your-session-secret-key
echo.
echo # 系统配置
echo DEFAULT_PAGE_SIZE=20
echo MAX_PAGE_SIZE=100
echo.
echo # Swagger配置
echo SWAGGER_ENABLED=true
echo SWAGGER_PATH=/api-docs
echo.
echo # AI助手配置
echo DEEPSEEK_API_KEY=your-deepseek-api-key
echo DEEPSEEK_API_URL=https://api.deepseek.com/v1/chat/completions
) > .env

echo ✅ .env 文件已修复
echo 📁 原文件已备份为 .env.backup
echo 💡 请检查 DATABASE_URL 是否正确配置

pause
